import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DppPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    // 构建标题栏的内容
    return Container(
      color: Colors.transparent, // 标题栏的背景颜色
      alignment: Alignment.center, // 内容的对齐方式
      padding: EdgeInsets.only(top: 20),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Image.asset(
            'assets/images/dapp/loading.png',
            width: 14.w,
            height: 14.w,
          ),
          const SizedBox(
            width: 7,
          ),
          Text('loading...')
        ],
      ), // 标题栏的内容
    );
  }

  @override
  double get maxExtent => 102.0; // 标题栏的最大高度

  @override
  double get minExtent => 50.0; // 标题栏的最小高度

  @override
  bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
    return false; // 是否在滚动时重建标题栏
  }
}
